<%-- 
    Document   : apuesta_individual
    Created on : 24/11/2009, 09:39:20 PM
    Author     : Juan Garza
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="Model.JConexion"%>
<%@page import="java.util.ArrayList" %>
<%@page import="java.util.Iterator" %>
<%@page import="javax.servlet.http.HttpServlet" %>
<%@page import="javax.servlet.http.HttpServletRequest" %>
<%@page import="javax.servlet.http.HttpServletResponse" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Haz tu Apuesta</title>
    </head>
    <body>
        <%
            String idcarrera="";
            String user="";
                //if(!(idcarrera.equals(null))&&!(user.equals(null))){
            idcarrera = request.getParameter("idcarrera");
            user = request.getParameter("user");
                //}
        %>
        <form action="<% out.println("http://" + request.getLocalName() + ":" + request.getLocalPort() + "/RoyalMowes/C_Apuesta_individual?idcarrera=" + idcarrera + "&user=" + user); %>" method="post">
        <%                
                //out.println("car: " + idcarrera);
                //out.println("usr: " + user);
                String query="";
                String[] dat;
                ArrayList al = new ArrayList();
                JConexion jc = new JConexion("");
                Iterator it = null;
                query = "SELECT ca.id_caballo, ca.nombre FROM rel_carrera_caballo r, cat_caballo ca WHERE r.fk_id_carrera = " + Integer.parseInt(idcarrera) + " and ca.id_caballo = r.fk_id_caballo;";
                al.clear();
                al = jc.MySQLArray("MySQLRM", "Consulta", query);
                it = al.iterator();
                int pos = 0;               
          %>
        <br>
        <br>
        <center>
            <h1>Escribe la cantidad a apostar, y la posicion en que llegara el caballo!!!</h1>
            <table>
                <tr>                    
                    <th align="leftt">Caballo:</th><td><select name="idcaballo">
                            <%
                                while(it.hasNext()){
                                    dat = (String[]) al.get(pos);
                            %>
                            <option value="<% out.println(dat[0].toString()); %>"><% out.println(dat[1].toString()); %></option>
                            <%
                                    it.next();
                                    pos++;
                                }
                            %>
                        </select></td>
                </tr>
                <tr>
                    <th align="left">Apuesta: </th><td><input type="text" name="apuesta" title="Aqui coloca tu nombre"></td>
                </tr><tr>
                    <th align="left">Posicion: </th><td><select name="posicion">                            
                            <option value="1">WIN</option>
                            <option value="2">PLACE</option>
                            <option value="3">SHOW</option>
                        </select></td>
                </tr><tr>
                    <td colspan="2"><input type="submit" name="apostar" value="Apostar" title="Registra los datos ingresados"></td>
                </tr>
                
            </table>
        </center>
        </form>
    </body>
</html>
